<extend name="Public:base" />
<block name="body">
<style type="text/css">

</style>
<!--引入弹窗插件-->
<include file="Public:artdialog" />

 <div class="main-content">
        <div class="breadcrumbs" id="breadcrumbs">
            <script type="text/javascript">
                try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
            </script>
            <ul class="breadcrumb">
                <li>
                    <i class="icon-home home-icon"></i>
                    <a href="__APP__/{$parent_nav.name_url}">{$parent_nav.name}</a>
                </li>
                <li class="active">{$one_nav.name}</li>
            </ul><!-- .breadcrumb -->
        </div>

<div class="page-content">
<div class="header">
<div class="row">
 <div class="col-xs-12">
        

<form class="form-horizontal" role="form" id="pwd_form">
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 原密码 </label>

                                        <div class="col-sm-9">
                                            <input type="password" id="old_pwd" name="old_pwd"  placeholder="请输入原密码" onblur="check_old_pwd(this,1)" class="col-xs-10 col-sm-5">
                                              <span  style="display:none"> <i class="icon-ok green" ></i></span>
                                               
                                        </div>
                                    </div>

                                    <div class="space-4"></div>

                                    <div class="form-group">
                                        <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 新密码 </label>

                                        <div class="col-sm-9">
                                            <input type="password" id="new_pwd" name="new_pwd" placeholder="请输入新密码"  onblur="check_old_pwd(this,0)" class="col-xs-10 col-sm-5">
                                                <span  style="display:none"> <i class="icon-ok green" ></i></span>
                                        </div>
                                    </div>

                                    <div class="space-4"></div>

                                    <div class="form-group">
                                        <label class="col-sm-3 control-label no-padding-right"  for="form-input-readonly"> 密码确认 </label>

                                        <div class="col-sm-9">
                                            <input  type="password" class="col-xs-10 col-sm-5" id="re_pwd" name="re_pwd" placeholder="请重复新密码"  onblur="check_old_pwd(this,2)"  >
                                            <span  style="display:none"> <i class="icon-ok green" ></i></span>
                                        </div>
                                    </div>



                                    <div class="clearfix form-actions">
                                        <div class="col-md-offset-3 col-md-9">
                                            <button class="btn btn-info" type="button" onclick="sub_pwd()">
                                                <i class="icon-ok bigger-110"></i>
                                                提交
                                            </button>
                                        </div>
                                    </div>
                                </form>
    </div>

</div>
</div>
<script type="text/javascript">
 var pwd_status = 0;
 var pwd_confirm = 0;

  function check_old_pwd(_this,type){
      //验证密码
      var pwd = $(_this).val();
      if(pwd == "" || pwd.length<4 || pwd.length >16){
         // showvfmsg(0, '密码格式错误！', 1900);
         $(_this).parent().children('span').show();
         $(_this).parent().children('span').html('<i class="icon-remove red"></i>');
         return false;
      }else{
          $(_this).parent().children('span').show();
         $(_this).parent().children('span').html('<i class="icon-ok green"></i>');
      }

        if(type==2){
            var new_pwd = $('#new_pwd').val();
            if(pwd == new_pwd){
                pwd_confirm =1
                $(_this).parent().children('span').show();
                $(_this).parent().children('span').html('<i class="icon-ok green"></i>');
            }else{
                $(_this).parent().children('span').show();
               $(_this).parent().children('span').html('<i class="icon-remove red"></i>');   
            }
        }
        if(type ==1){
               var url = "{:U('User/upd_pwd')}";
                  $.ajax({
                            'url':url,
                            'data':{pwd:pwd},
                            'dataType':'json',
                            'type':'post',
                            success:function(data){
                               
                                var retstatus = data.state == 1 ? "1" : "0";
                                  $(_this).parent().children('span').show();
                                if(retstatus == 1){
                                    pwd_status =1;
                                    $(_this).parent().children('span').html('<i class="icon-ok green"></i>');
                                }else{
                                    $(_this).parent().children('span').html('<i class="icon-remove red"></i>');
                                     pwd_status = 0;
                                    // showvfmsg(retstatus, data.msg, 1900);
                                }
                                

                            },error:function(){
                                showvfmsg('error','请求服务器失败',2000);
                            },complete:function(){

                            }
                        });   
        }

  }
   

function sub_pwd(){
   if(pwd_status != 1  ){
       showvfmsg(0, '原密码错误', 1900);
       return false;
   }
   if(pwd_confirm !=1){
      showvfmsg(0, '两次输入的密码不一样', 1900);
      return false;
   }
  var url="{:U('User/save_pwd')}";
                $.ajax({
                    'url':url,
                    'data':$('#pwd_form').serialize(),
                    'dataType':'json',
                    'type':'post',
                    success:function(data){
                         var retstatus = data.state == 1 ? "1" : "0";
                          showvfmsg(retstatus, data.msg, 1900);
                          if(retstatus ==1){
                            window.location.reload();
                          }
                    },error:function(){
                        showvfmsg('error','请求服务器失败',2000);
                    },complete:function(){

                    }
                });
}    

function _es_openDilog90(url, title,id){ 
     art.dialog.open(url, { title: title, width: '1200px', height: '90%', opacity: 0.2, id: id, fixed: true, close:function(){load();}  });
}


    function delete_ok(id){
        art.dialog({
            content: "确定要删除吗？",
            icon: 'question',
            lock: true,
            opacity: 0.2,
            id:'dele',
            ok: function () {
                var url="{:U('Nav/delete_admin_ok')}";
                $.ajax({
                    'url':url,
                    'data':{id:id},
                    'dataType':'json',
                    'type':'post',
                    success:function(data){
                        goSearch("#searchForm","order_list_item_content");
                        //_reload_currentpage_datalist('order_list_item_content');
                        // goSearch("#searchForm","order_list_item_content");
                        var retstatus = data.status == 1 ? "1" : "0";
                        showvfmsg(retstatus, data.info, 1900);

                    },error:function(){
                        showvfmsg('error','请求服务器失败',2000);
                    },complete:function(){

                    }
                });


            },
            cancelVal: '取消',
            cancel: true
        });
    }
</script>
</block>
